﻿Imports System.Data
Imports System.Data.OleDb
Imports geraLaudosAutomatico.conexao
Imports System.Text

Public Class calibreDAO
    Private sql As New StringBuilder
    Private objConn As New conexao
    Public Function getCalibres(Optional ByVal EHESPINGARDA As Boolean = Nothing) As DataTable

        sql.Clear()
        sql.Append("SELECT *FROM CALIBRE ")
        If EHESPINGARDA Then
            sql.Append(" WHERE ID_CALIBRE IN (9,10,11,12,13,14,15)")
        Else
            sql.Append(" WHERE ID_CALIBRE NOT IN (9,10,11,12,13,14,15)")
        End If
        sql.Append(" ORDER BY CALIBRE")
        Dim DS As New DataSet
        Try
            Dim comando As New OleDbCommand(sql.ToString, objConn.abreConexao(False))
            Dim adaptador As New OleDbDataAdapter(comando)
            adaptador.Fill(DS, "CALIBRE")
        Catch ex As Exception
            Throw ex
        End Try
        Return DS.Tables("CALIBRE")
    End Function

    Public Function getTodosCalibres() As DataTable

        sql.Clear()
        sql.Append("SELECT *FROM CALIBRE ORDER BY CALIBRE")

        Dim DS As New DataSet
        Try
            Dim comando As New OleDbCommand(sql.ToString, objConn.abreConexao(False))
            Dim adaptador As New OleDbDataAdapter(comando)
            adaptador.Fill(DS, "CALIBRE")
        Catch ex As Exception
            Throw ex
        End Try
        Return DS.Tables("CALIBRE")
    End Function

End Class
